$(function(){

    $.ajaxPrefilter(function (options, originalOptions, jqXHR){

        idCardName="manage-system-backed-idCard";


        options.url = "http://localhost:8090/manage-sys" +options.url ;




        if(options.url.indexOf("/Lock") != -1){

            console.log(0);

            idCard=localStorage.getItem(idCardName) || "" ;
            if(Object.prototype.toString.call(options.data) == "[object FormData]"){
                options.data.append("idCard",idCard);
            }else if(Object.prototype.toString.call(options.data) == "[object String]"){
                if(Object.prototype.toString.call(originalOptions.data) == "[object Object]"){
                    options.data = $.param($.extend(originalOptions.data||{}, {
                        "idCard": idCard
                    }));
                }else if(Object.prototype.toString.call(originalOptions.data) == "[object String]"){
                    options.data = options.data+"&idCard="+idCard;
                }
            }

        }


        // 权限控制
        options.complete= function(req){
            console.log("ajaxfilter,控制权限跳转的页面");
            if(req.responseJSON.statue == 4){
                localStorage.removeItem(idCardName);
                location.href = "../Login/index.html"
            }
        }
    });
})